<?php
/**
 * 获取栏目的树状结构
 * @return [type] [description]
 */
function categoryTree($data,$pid=0,$level=0)
{
	static $arr=array();
	
	foreach($data as $d)
	{
		if($d['pid']==$pid)
		{
			$d['_cname'] = str_repeat('-', $level*3).$d['cname'];
			$arr[]=$d;
			categoryTree($data,$d['id'],$level+1);
		}
	}
	return $arr;
}
function p($data)
{
	echo "<pre>".print_r($data,true);
}